package com.cyandpos.pad.tradedetails.adapter;

import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.cyandpos.pad.R;
import com.cyandpos.pad.activity.DetailsActivity;
import com.cyandpos.pad.posdata.Goods;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TradeDetailsiinfoAdapter extends RecyclerView.Adapter<TradeDetailsiinfoAdapter.GoodsHolderr>  {

    private LayoutInflater mLayoutInflater;
    private ArrayList<Goods> mDatas;
    private DetailsActivity mContext;
    public TradeDetailsiinfoAdapter(Context context, ArrayList<Goods> goodsList) {
        mContext = (DetailsActivity) context;
        this.mDatas = goodsList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }
    @Override
    public GoodsHolderr onCreateViewHolder(ViewGroup parent, int viewType) {
        return new GoodsHolderr(mLayoutInflater.inflate(R.layout.list_trad_iteme, parent, false));
    }

    @Override
    public void onBindViewHolder(GoodsHolderr holder,final int position) {
        holder.mGood_xh.setText(mDatas.get(position).getTicktGoodsInx()+"/"+mDatas.get(position).getTicktInx());
        holder.mGoodCode.setText(mDatas.get(position).getBarCode());
        holder.mGoodName.setText(mDatas.get(position).getName() + "(" + mDatas.get(position).getCode() + ")");
        holder.mGoodCount.setText(mDatas.get(position).getRefundCount());
        holder.mGoodPrice.setText(mDatas.get(position).getPrice());
        holder.mYH.setText(mDatas.get(position).getDiscount());
    }


    @Override
    public int getItemCount() {
        return mDatas.size();
    }

    class GoodsHolderr extends RecyclerView.ViewHolder {
        @BindView(R.id.good_xh)
        TextView mGood_xh;
        @BindView(R.id.good_name)
        TextView mGoodName;
        @BindView(R.id.tv_sale_good_code)
        TextView mGoodCode;
        @BindView(R.id.good_count)
        TextView mGoodCount;
        @BindView(R.id.good_price)
        TextView mGoodPrice;
        @BindView(R.id.YH)
        TextView mYH;
        @BindView(R.id.money)
        TextView mMoney;
        @BindView(R.id.img_sale_goods_cut)
        ImageView mIvLeftSj;
//        @BindView(R.id.refund_count)
//        TextView mRefundCount;
        @BindView(R.id.img_sale_goods_add)
        ImageView mIvRightSj;
//        @BindView(R.id.discount)
//        TextView mDiscount;


        public GoodsHolderr(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
